package auth

import (
	"gitee.com/baizhige/simple-auth-go/schema"
	"gitee.com/baizhige/simple-auth-go/util"
)

var cache schema.Cache
var apiMap map[string]*schema.ApiInfo

func Init[T schema.Cache](jsonCache T, allApi []*schema.ApiInfo) {
	cache = jsonCache
	apiMap = util.ArrToMap(allApi, func(item *schema.ApiInfo) string {
		return apiKey(item.Method, item.Path)
	})
}

func apiKey(method, path string) string {
	return method + ":" + path
}
